package com.fs.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.swing.text.html.ListView;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.fs.dao.ProductDao;
import com.fs.dao.ProductDetailsDao;
import com.fs.entity.Product;

@WebServlet("/details.do")
public class ProductDetails extends HttpServlet{
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
			PrintWriter out=resp.getWriter();
			String type=req.getParameter("type");
			ProductDetailsDao prddao=new ProductDetailsDao();
			HttpSession session=req.getSession();
			JSONObject json = new JSONObject();
			if("query".equals(type)){
				
				int product_id=Integer.parseInt(req.getParameter("productID"));		 
				System.out.println(product_id+"query");
				Product proinfo=prddao.queryProductDetailsInfo(product_id);
				req.setAttribute("proinfo",proinfo);
				req.getRequestDispatcher("introduction.jsp").forward(req, resp);
			}
		}
}

